package com.bao.camelcase;

public class CamelCase {

    public static String convertToCamelCase(String[] words) {
        StringBuilder camelCaseName = new StringBuilder();
        for (int index = 0; index < words.length; index++) {
            words[index] = words[index].toLowerCase();
            int firstWord = 0;
            if (index == firstWord) {
                camelCaseName.append(words[firstWord]);
                continue;
            }
            int firstLetter = 0;
            char letters[] = words[index].toCharArray();
            letters[firstLetter] = Character.toUpperCase(letters[firstLetter]);
            words[index] = new String(letters);
            camelCaseName.append(words[index]);
        }
        String result = camelCaseName.toString();
        result = result.replaceAll(" ", "");
        return result;
    }

    public static void main(String[] args) {
        String inputWords[] = {"Get", "first", "REFERENCE"};
        System.out.println("Converted name to Camel Case:");
        System.out.println(convertToCamelCase(inputWords));

    }
}

